<?php
$configNameField = 'media_name_onlineOrderConfig_info';
$configDescriptionField = 'media_description_onlineOrderConfig_info';
$configActiveTimeField = 'media_activeTime_onlineOrderConfig_info';
$configExpireTimeField = 'media_expireTime_onlineOrderConfig_info';
$priceTypeField = 'media_priceType_onlineOrderConfig_info';
$model->addField($configNameField);
$model->addField($configDescriptionField);
$model->addField($configActiveTimeField);
$model->addField($configExpireTimeField);
$model->addField($priceTypeField);

$configTable = new BPSheet('orderConfig');
if (isset($configId) && $configId > 0) {
    $config = $configTable->getListById($configId);

    $nameItem = $config->getItem('name');
    if ($nameItem instanceof BTreeItem) {
        $configName = $nameItem->getValue();
        $model->$configNameField = $configName;
    }

    $descItem = $config->getItem('description');
    if ($descItem instanceof BTreeItem) {
        $configDescription = $descItem->getValue();
        $model->$configDescriptionField = $configDescription;
    }

    $activeItem = $config->getItem('activeTime');
    if ($activeItem instanceof BTreeItem) {
        $configActiveTime = $activeItem->getValue();
        $model->$configActiveTimeField = $configActiveTime;
    }

    $expirtItem = $config->getItem('expireTime');
    if ($expirtItem instanceof BTreeItem) {
        $configExpireTime = $expirtItem->getValue();
        $model->$configExpireTimeField = $configExpireTime;
    }

    $priceItem = $config->getItem('priceType');
    if ($priceItem instanceof BTreeItem) {
        $priceType = $priceItem->getValue();
        $model->$priceTypeField = $priceType;
    }
}
?>
<?php
$app = Blyn::app()->getActiveApp();
?>
<script type="text/javascript">
    $(function() {
        $('#datetimepicker1<?php echo $configId ?>').datetimepicker({
            language: 'pt-BR'
        });
        $('#datetimepicker2<?php echo $configId ?>').datetimepicker({
            language: 'pt-BR'
        });
    });</script>
<legend><h4>
        <?php echo $control->getAjaxLink(array('name' => '活动列表', 'id' => 'showEventList')); ?>\
        <?php echo $control->getAjaxLink(array('name' => '配置列表', 'id' => 'showOrderConfigList'), array('eventId' => $eventId)); ?>\
        <?php echo '添加配置信息'; ?>
    </h4>
</legend>
<table class="table table-hover">
    <colgroup>
        <col class="span1">
        <col class="span7">
    </colgroup>
    <thead>
        <tr>
            <th><?php echo '属性'; ?></th>
            <th><?php echo '内容'; ?></th>
        </tr>
    </thead>
    <tbody>
        <tr><td> <?php echo '名称'; ?> </td>
            <td>
                <?php
                echo $form->textField($model, $configNameField, array('placeholder' => '名称' . '...', 'required' => true));
                ?>
            </td>
        </tr>               
        <tr>
            <td> <?php echo '简介'; ?>  </td>                    
            <td>
                <?php
                echo $form->textArea($model, $configDescriptionField, array('placeholder' => '简介' . '...'));
                ?>
        </tr>
        <tr>
            <td>
                <?php echo '启用时间'; ?>
            </td>
            <td>
            <div class="input-append" id="datetimepicker1<?php echo $configId ?>">
                <?php
                echo $form->textField($model, $configActiveTimeField, array('data-format' => "yyyy-MM-dd hh:mm:ss", 'type' => "text", 'placeholder' => '启用时间' . '...', 'required' => true));
                ?>
                <span class="add-on">
                    <i data-date-icon="icon-calendar" data-time-icon="icon-time" class="icon-calendar">
                    </i>
                </span>
            </div> 
                <?php
//                echo $form->textField($model, $configActiveTimeField, array('placeholder' => '启用时间' . '...', 'required' => true));
                ?>
                <!--                    &nbsp;&nbsp;&nbsp;&nbsp;<a id="CreateNewType_clink" role="button" data-toggle="modal" class="btn disabled" style="font-size: 12px;margin-top: -12px;">创建新类型</a>-->
            </td>
        </tr>
        <tr>
            <td>
                <?php echo '截止时间'; ?>
            </td>
            <td>
               <div class="input-append" id="datetimepicker2<?php echo $configId ?>">
                <?php
                echo $form->textField($model, $configExpireTimeField, array('data-format' => "yyyy-MM-dd hh:mm:ss", 'type' => "text", 'placeholder' => '截止时间' . '...', 'required' => true));
                ?>
                <span class="add-on">
                    <i data-date-icon="icon-calendar" data-time-icon="icon-time" class="icon-calendar">
                    </i>
                </span>
            </div> 
                <?php
//                echo $form->textField($model, $configExpireTimeField, array('placeholder' => '截止时间' . '...', 'required' => true));
                ?>
                <!--                    &nbsp;&nbsp;&nbsp;&nbsp;<a id="CreateNewType_clink" role="button" data-toggle="modal" class="btn disabled" style="font-size: 12px;margin-top: -12px;">创建新类型</a>-->
            </td>
        </tr>
        <tr>
            <td>
                <?php echo '定价方式'; ?>
            </td>
            <td>
                <?php
                echo $form->dropDownList($model, $priceTypeField, $app->getPriceTypeList(), array('required' => true));
                ?>
                <!--                    &nbsp;&nbsp;&nbsp;&nbsp;<a id="CreateNewType_clink" role="button" data-toggle="modal" class="btn disabled" style="font-size: 12px;margin-top: -12px;">创建新类型</a>-->
            </td>
        </tr>
    </tbody>
</table>